package t4tools.etodo.views.providers;

import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;

import t4tools.etodo.model.TreeElement;

public class ViewContentProvider implements IStructuredContentProvider, ITreeContentProvider {

	@Override
	public void inputChanged(Viewer v, Object oldInput, Object newInput) {
	}

	@Override
	public void dispose() {
	}

	@Override
	public Object[] getElements(Object parent) {
		return getChildren(parent);
	}

	@Override
	public Object getParent(Object child) {
		return ((TreeElement) child).getParent();
	}

	@Override
	public Object[] getChildren(Object parent) {
		return ((TreeElement) parent).getChildren().toArray(new TreeElement[] {});
	}

	@Override
	public boolean hasChildren(Object parent) {
		return ((TreeElement) parent).hasChildrent();
	}

}